﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SBPweb.Messenger.ClientApplication.Controls
{
    public partial class PopupDialog : UserControl
    {

        public PopupDialog()
        {
            InitializeComponent();

            App.Current.Host.Content.Resized += (s, e) =>
            {
                theBack.Width = App.Current.Host.Content.ActualWidth;
                theBack.Height = App.Current.Host.Content.ActualHeight;
            };

        }

        public IPopupDialogContentControl ContentControl
        {
            get
            {
                return cContent.Content as IPopupDialogContentControl;
            }
            protected set
            {
                cContent.Content = value;
            }
        }

        public static void ShowDialog(IPopupDialogContentControl content, string closeButtonText, RoutedEventHandler onCloseCallBack)
        {
            MainWindow mw = (System.Windows.Application.Current.RootVisual as MainWindow);
            PopupDialog pd = mw.pdLogin;

            pd.ContentControl = content;
            pd.fakeDialog.IsOpen = true;
            pd.closeButton.Content = closeButtonText;
            pd.closeButton.Click += new RoutedEventHandler(onCloseCallBack);
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            fakeDialog.IsOpen = false;
        }
    }
}
